<?php
// 模拟黄历数据
$lunarCalendarData = [
    "2025-02-13" => [
        "lunar_date" => "甲辰年正月十四",
        "solar_term" => "",
        "auspicious" => "祭祀、祈福、求嗣、开光、出行、解除、伐木、出火、入宅、移徙、安床、拆卸、修造、安门、纳畜、启攒、安葬",
        "inauspicious" => "嫁娶、动土、破土",
        "gods" => "喜神：东北 福神：正北 财神：正东"
    ]
];

// 获取当前日期
$currentDate = date("Y-m-d");

// 如果有指定日期查询
if (isset($_GET['date'])) {
    $queryDate = $_GET['date'];
    if (array_key_exists($queryDate, $lunarCalendarData)) {
        $selectedDateData = $lunarCalendarData[$queryDate];
    } else {
        $selectedDateData = null;
    }
} else {
    $queryDate = $currentDate;
    if (array_key_exists($currentDate, $lunarCalendarData)) {
        $selectedDateData = $lunarCalendarData[$currentDate];
    } else {
        $selectedDateData = null;
    }
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查黄历游戏</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <h1>查黄历游戏</h1>
    <form method="get">
        <label for="date">请选择日期：</label>
        <input type="date" name="date" id="date" value="<?php echo $queryDate; ?>">
        <input type="submit" value="查询">
    </form>
    <?php if ($selectedDateData): ?>
        <div id="result">
            <h2><?php echo $queryDate; ?> 黄历信息</h2>
            <p>农历日期：<?php echo $selectedDateData['lunar_date']; ?></p>
            <p>节气：<?php echo $selectedDateData['solar_term'] ?: '无'; ?></p>
            <p>宜：<?php echo $selectedDateData['auspicious']; ?></p>
            <p>忌：<?php echo $selectedDateData['inauspicious']; ?></p>
            <p>吉神方位：<?php echo $selectedDateData['gods']; ?></p>
        </div>
    <?php else: ?>
        <div id="result">
            <p>暂无该日期的黄历信息。</p>
        </div>
    <?php endif; ?>
</body>

</html>